<style lang="scss" scoped>
	.content {

		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.nav {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		border-bottom: 1px solid #dee2ee;
		z-index:999;
	}

	.top {
		padding: 20rpx 0;
	}

	.search {
		width: 690rpx;
		height: 68rpx;
		background: #f4f5f7;
		border: 2rpx solid #f5f5f5;
		border-radius: 46rpx;
		margin: 0rpx auto;
		padding: 20rpx;

		.ipt {
			flex: 1;
		}
	}

	.lists {
		margin-bottom: 50rpx;

		.list {
			width: 690rpx;

			opacity: 1;
			background: #ffffff;
			border-radius: 20rpx;
			box-shadow: 0rpx 30rpx 18rpx -14rpx #e6ebf2;
			overflow: hidden;
			margin-top: 30rpx;

			.head {
				width: 100%;
				border-bottom: 1px solid #eee;
				padding: 20rpx 0;

				>view {
					padding: 0 20rpx;
					width: 50%;
				}
			}

			.contains {
				width: 100%;
				padding: 20rpx;

				.text {
					width: 620rpx;
					line-height: 60rpx;

					.h1 {
						width: 140rpx;

					}

					.between-flex {
						>view {
							width: 50%;
						}
					}
				}
			}


		}
	}
</style>

<template>
	<view class="content">
		<view class="nav bgwhite" id="nav">
			<view class="top bgwhite">
				<view class="search align-flex">
					<u-icon name="search" color="#666" size="34"></u-icon>
					<input class="ipt p-left20" type="text" v-model="keywords" @input="search()"
						placeholder="搜索关键字/词" />
				</view>
			</view>
		</view>
		<view :style="'height:'+navheight+'px;'"></view>
		<view class="lists">
			<view class="list" v-for="item,index in list" :key="index">
				<view class="head flex">
					<view class="tips gray">
						签订时间: 2021-09-03
					</view>
					<view class="ordernum f28 gray">
						<view class="between-flex">
							<view class="f26 " :style="{color:paystate[item.payState-1].color}">
								{{paystate[item.payState-1].name}}</view>
							<view class="f26 "  :style="{color:fapiaostate[item.receiptState-1].color}">
								{{fapiaostate[item.receiptState-1].name}}
							</view>
						</view>
					</view>
				</view>
				<view class="contains between-flex" @click="$navTo('/pages/fapiao/fapiaoDetail?id='+item.id)">
					<view class="text">
						<view class="f34 bold textColor">{{item.name}}</view>
						<view class="align-flex">
							<view class="gray h1">合同金额:</view><span class="textColor">￥{{item.contractPrice | price}}</span>
						</view>
						<view class="between-flex">
							<view class="align-flex">
								<view class="gray h1">已付金额:</view><span class="textColor">￥{{item.paidPrice | price}}</span>
							</view>
							<view class="align-flex">
								<view class="gray h1">待付金额:</view><span class="textColor">￥{{item.unpaidPrice | price}}</span>
							</view>
						</view>
						<view class="between-flex">
							<view class="align-flex">
								<view class="gray h1">已开发票:</view><span
									class="textColor">￥{{item.paidReceiptPrice | price}}</span>
							</view>
							<view class="align-flex">
								<view class="gray h1">待开发票:</view><span
									class="textColor">￥{{item.unpaidReceiptPrice | price}}</span>
							</view>
						</view>
						<view class="align-flex">
							<view class="gray h1">乙方单位:</view><span class="textColor">这里是内容</span>
						</view>
					</view>
					<u-icon name="arrow-right" color="#98a5b3" size="28"></u-icon>
				</view>

			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				navheight: 0,
				head: this.$head,
				itemCode: 0,
				officeId: 0,
				page: 1,
				list: [],
				nomore: false,
				empty: false,
				keywords: '',
				paystate: [

					{
						name: '未付',
						color: '#F56C6C'
					},
					{
						name: '部分已付',
						color: '#EBB917'
					},
					{
						name: '全部已付',
						color: '#07C160'
					}
				],
				fapiaostate: [{
						name: '未开',
						color: '#F56C6C'
					},
					{
						name: '部分已开',
						color: '#EBB917'
					},

					{
						name: '全部已开',
						color: '#07C160'
					}
				]
			}
		},
		onLoad(e) {

			this.$nextTick(() => {
				let info = uni.createSelectorQuery().select("#nav");
				info.boundingClientRect((data) => {

					this.navheight = data.height

					console.log(this.navheight)
				}).exec()

			})
			this.itemCode = e.itemCode
			this.reset()
		},
		onReachBottom() {
			if (!this.nomore) {
				this.page++
				this.getlist()
			}
		},
		methods: {
			search() {
				this.$u.debounce(this.reset, 500)

			},
			reset() {
				this.$showloading()
				this.page = 1
				this.list = []
				this.nomore = false
				this.getlist()

			},
			getlist() {

				this.$pop.ajaxPost('/contract/list', {
					  itemCode: this.itemCode,
					name:this.keywords,
					pageSize: 10,
					pageNum: this.page
				}).then(res => {
					uni.hideLoading()
					var list = res.body.list

					this.list = this.list.concat(list)

					if (this.list.length == 0) {
						this.empty = true
					} else {
						this.empty = false
						if (list.length < 10) {
							this.nomore = true
						} else {
							this.nomore = false
						}
					}
					// console.log(this.list)
				})
			},


		}
	}
</script>
